#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std; 

#define N	10000

int a[N]; 
int n, m; 

void dump(void)
{
	int i; 
	
	for (i=0; i<n; i++) {
		printf("%d ", a[i]); 
		if (((i+1)%20)==0) {
			printf("\n"); 
		}
	}
	printf("\n"); 
}

void inc(void)
{
	int i, j, k; 
	
	if (n<=1)
		return; 

	for (i=n-2; i>=0; i--) {
		if (a[i]<a[i+1])
			break; 
	}
	k = i+1; 
	for (j=i+1; j<n; j++) {
		if (a[j]>a[i] && a[j]<a[k]) {
			k = j; 
		}
	}
	swap(a[i], a[k]); 
	sort(a+i+1, a+n); 
}

int main()
{
	int i; 
	
	//freopen("p1088_1.in", "r", stdin); 
	
	cin>>n>>m; 
	for (i=0; i<n; i++) {
		cin>>a[i]; 
	}

	for (i=0; i<m; i++) {
		inc(); 
	}
	
	for (i=0; i<n; i++) {
		cout<<a[i]<<(i==n-1?"\n":" "); 
	}
	return 0; 
}



